﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Jzb.ConsoleApp
{
    public class Polymorphic
    {
        //父类Animal
        public class Animal
        {
            public virtual void MakeSound()
            {
                Console.WriteLine("The Animal makes a sound");
            }

        }
        // 定义一个子类，继承自Animal类并重写MakeSound方法  
        public class Cat : Animal
        {
            public override void MakeSound()   
            {
                Console.WriteLine("Meow");
            }
        }
        public class Dog : Animal
        {
            public override void MakeSound()
            {
                Console.WriteLine("Woof");
            }
        }
    }
}
